package com.cloud.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BaseFilterConfig {
    /**
     * 一个bean配置一个filter
     */
    @Bean("CloudBaseHeaderFilterBean")
    public FilterRegistrationBean getCloudBaseHeaderFilterBean() {
        FilterRegistrationBean filterBean = new FilterRegistrationBean(new CloudBaseHeaderFilter());
        //配置要应用的路径，如果有多个路径，写成String[]的形式
        filterBean.addUrlPatterns("/*");
        //设置执行顺序，浏览器->服务器时，数值越小的越先执行；服务器->浏览器则相反
        filterBean.setOrder(0);
        return filterBean;
    }
}
